
<%-- 
    Document   : AgregarSolicitudReserva
    Created on : 24/07/2008, 10:45:50 AM
    Author     : R2
--%>

<%@ page language="java" import="java.util.*" %>
<%@ page language="java" import="java.sql.*" %>
<%@ page language="java" import="com.akcess.vo.*" %>
<%@ page language="java" import="com.akcess.impl.*" %>
<%@ page language="java" import="manejadores.*" %>
<%@ page contentType="text/html" pageEncoding="UTF-8"%>

<%
            String path = request.getContextPath();
            String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";

%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en"><head>
        <!--  Version: Multiflex-3.12 / Overview                    --><!--  Date:    January 20, 2008                             --><!--  Design:  www.1234.info                                --><!--  License: Fully open source without restrictions.      --><!--           Please keep footer credits with the words    --><!--           "Design by 1234.info" Thank you!             -->
<!-- calendar stylesheet -->
  <link rel="stylesheet" type="text/css" media="all" href="./css/calendar-win2k-cold-1.css" title="win2k-cold-1" />

  <!-- main calendar program -->
  <script type="text/javascript" src="./js/calendar.js"></script>

  <!-- language for the calendar -->
  <script type="text/javascript" src="./js/calendar-es.js"></script>

  <!-- the following script defines the Calendar.setup helper function, which makes
       adding a calendar a matter of 1 or 2 lines of code. -->
  <script type="text/javascript" src="./js/calendar-setup.js"></script>

<script language="JavaScript">	
    <!--
    
    
    
    function nuevoAjax(){
        var xmlhttp=false;
        try {
            xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
        } catch (e) {
            try {
                xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (E) {
                xmlhttp = false;
            }
        }
        
        if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
            xmlhttp = new XMLHttpRequest();
        }
        return xmlhttp;
    } 
    function cargarContenido(){
        var cadena,t1,contenedor, ubica,nombre,CI;
        contenedor = document.getElementById('recurso');
        ubica= document.getElementById('Ubicacion');
        nombre=document.getElementById('nombreResp');
        CI=document.getElementById('numDoc');
        t1 = document.getElementById('TipoRecurso').value;
        if(t1=="#")
        {
            alert("Elegi na algo!")
        }
        else{
                if(t1=='Aula' || t1=='Sala' )
                    {
                        ubica.style.visibility ='hidden';
                        nombre.style.visibility='hidden';
                        CI.style.visibility='hidden';
                    }
                    
                else
                    {
                        ubica.style.visibility ='visible';
                        nombre.style.visibility='visible';
                        CI.style.visibility='visible';
                    }
                    
                ajax=nuevoAjax();
                ajax.open("GET", "GestionarReservas?hacer=listarAJAX&id="+t1,true);
                ajax.onreadystatechange=function() {
                if (ajax.readyState==4) {
                        cadena=ajax.responseText
                        if(cadena==" ")
                            alert("Lo siento, NO existe ningun recurso disponible de ese Tipo.")
                        cadena="<option>[Selecione un Recurso]</option>" +cadena  
                        contenedor.innerHTML = cadena
                    }
                }
                ajax.send(null)
        }
        
    }
    function evalua(formulario)
    {
        var idRecurso = formulario.recurso.value;
        var nombre = formulario.nombreOp.value;
        if(idRecurso=="[Selecione un Recurso]")
            alert("Debe elegir un recurso especifico...");
        else if(nombre.length==0)
            alert("Debe buscar algun solicitante para realizar la reserva...");
        else
            formulario.submit();
    }   
    //-->
    </script>


        <meta http-equiv="content-type" content="text/html; charset=utf-8">
        <meta http-equiv="cache-control" content="no-cache">
        <meta http-equiv="expires" content="3600">
        <meta name="revisit-after" content="2 days">
        <meta name="robots" content="index,follow">
        <meta name="publisher" content="Your publisher infos here ...">
        <meta name="copyright" content="Your copyright infos here ...">
        <meta name="author" content="Design: 1234.info / Modified: Your Name">
        <meta name="distribution" content="global">
        <meta name="description" content="Your page description here ...">
        <meta name="keywords" content="Your keywords, keywords, keywords, here ...">           
        <base href="<%=basePath%>">
        <link rel="stylesheet" type="text/css" media="screen,projection,print" href="./css/layout4_setup.css">
        <link rel="stylesheet" type="text/css" media="screen,projection,print" href="./css/layout4_text.css">
    <link rel="icon" type="image/x-icon" href="./img/favicon.ico"><title>SRR - Sistema de Reserva de Recursos</title><!-- Global IE fix to avoid layout crash when single word size wider than column width --><!--[if IE]><style type="text/css"> body {word-wrap: break-word;}</style><![endif]--><link href="./css/highlighter.css" type="text/css" rel="stylesheet"><link href="./css/highlighter_002.css" type="text/css" rel="stylesheet"></head><body>
        <!-- Main Page Container -->
        <div class="page-container">
        
        <!-- For alternative headers START PASTE here -->

    <!-- A. HEADER -->      
            <jsp:include page="../Header.jsp"/>
            
            <!-- For alternative headers END PASTE here -->

        <!-- B. MAIN -->
        <div class="main">
            
            <!-- B.1 MAIN NAVIGATION -->
                <jsp:include page="../barraOperaciones.jsp"/> 
                
            <!-- B.2 MAIN CONTENT -->
            <div class="main-content">
                
                <!-- Pagetitle -->
                <h1 class="pagetitle">Solicitud de Reserva</h1>
                <form name="crear" action="GestionarSolicitudes_de_Reserva?hacer=crear" method="post">
                    <table border="1">
                        <tbody>                           
                            <%
                     Connection cone;
                     cone = (Connection) session.getAttribute("conexion");
                     Reserva reserva = new Reserva();
                     ManejadorReservas manejadorReserva = new ManejadorReservas(cone);
                     Ubicacion[] ubicaciones = manejadorReserva.ObtenerUbicaciones();
                     
                            %>                   

                        <tr>
                            <th class="top"> Fecha Reserva</th>
                            <td><input type="text" id="fecha_reserva" readonly="1" name="Fecha_Reserva"> </td>
                        </tr>
                        <script language="JavaScript">	
                            function controlFecha(cal) {
                                var date = cal.date;
                                var dateAyer = new Date();
                                var time= dateAyer.getTime();
                                time-=Date.DAY;
                                dateAyer=new Date(time)
                                var field = document.getElementById("fecha_reserva");
                                
                                if(date<dateAyer)
                                    {
                                        alert("La fecha de reserva es anterior a la fecha actual")
                                        var hoy=new Date();
                                        field.value = hoy.print("%Y-%m-%d");
                                    }
                                    
                                else     
                                    field.value = date.print("%Y-%m-%d");
                            }

                            Calendar.setup({
                            inputField     :    "fecha_reserva",   // id of the input field
                            ifFormat       :    "%Y-%m-%d",       // format of the input field
                            showsTime      :    false,
                            timeFormat     :    "24" ,
                            onUpdate       :    controlFecha
                            });
                        </script> 
                        
                        <%
                        out.println("<tr>");
                        out.println("<th class=\"top\">Hora de Inicio</th>");
                        out.println("<td><select name=\"hHora_de_Inicio\">");
                        for (int j = 7; j < 22; j++) {
                            out.println("<option value=" + j + "> " + j+"</option>");
                        }
                        out.println("</select> ");
                        out.println("<select name=\"mHora_de_Inicio\">");
                        for (int j = 0; j < 60; j = j + 15) {
                            if(j==0)
                                out.println("<option value=00>00 </option>");
                            else
                                out.println("<option value=" + j + "> " + j+"</option>");
                        }
                        out.println("</select>");
                        out.println("</td>");
                        out.println("</tr>");
                        
                        out.println("<tr>");
                        out.println("<th class=\"top\">Hora de Fin</th>");
                        out.println("<td><select name=\"hHora_de_Fin\">");
                        for (int j = 7; j < 22; j++) {
                            out.println("<option value=" + j + "> " + j+"</option>");
                        }
                        out.println("</select> ");
                        out.println("<select name=\"mHora_de_Fin\">");
                        for (int j = 0; j < 60; j = j + 15) {
                            if(j==0)
                                out.println("<option value=00>00 </option>");
                            else
                                out.println("<option value=" + j + "> " + j+"</option>");
                        }
                        out.println("</select>");
                        out.println("</td>");
                        out.println("</tr>");
                    
                     %>
                     
<%   
                            Tipo_recursoDAOImpl tiposR= new Tipo_recursoDAOImpl();
                           Tipo_recurso[] vecTipos= tiposR.findAll(cone);
                           
                           if(vecTipos.length!=0)
                           {
                                out.println("<tr>");
                                out.println("<th class=\"top\">");
                                out.println("Tipos de Recursos");
                                out.println("</th>");
                                out.println("<td>");
                                out.println("<select name=TipoRecurso id=TipoRecurso onchange=\"cargarContenido()\">");
                                out.println("<option value=\"#\"> [Seleccione el Tipo de recurso]</option>");
                                out.println("<option value=\"Aula\"> Aulas</option>");
                                out.println("<option value=\"Sala\"> Sala de Maquinas</option>");
                                for (int j = 0; j < vecTipos.length; j++) {
                                     out.println("<option value=" + vecTipos[j].getId_tipo_recurso() + "> " + vecTipos[j].getNombre()+"</option>");
                                }
                                out.println("</select>");
                                out.println("</td>");
                                out.println("</tr>");
                                out.println("<tr>");
                                    out.println("<th class=\"top\">");
                                        out.println("Recursos");
                                    out.println("</th>");
                                    out.println("<td>");%>
                                    
                                <select name="recurso" id="recurso">
                                        <option value="ape">[Selecione un Recurso]</option>
                                </select>
                                
                                 <% 
                                    out.println("</td>");
                                    out.println("</tr>");
                            }else{
                                    out.println("<div class=mensageError> No existen Tipos de recursos moviles definidos...</div>");
                            }
                   
                            %>    

                        <tr id="nombreResp">
                            <th class="top">Nombre Responsable</th>
                            <td><input type="text" name="Nombre_Responsable" value=""></td>
                        </tr>
                        <tr id="numDoc">
                            <th class="top">Numero de Documento</th>
                            <td><input type="text" name="Num_Doc_Responsable" value=""></td>
                        </tr>
                        
                        <%
                        out.println("<tr id=\"Ubicacion\">");
                        out.println("<th class=\"top\">Ubicacion</th>");
                        out.println("<td><select name=\"Ubicacion\">");
                        out.println("<option value=\"#\">[Elija una ubicacion]</option>");
                        for (int j = 0; j < ubicaciones.length; j++) {
                            out.println("<option value=" + ubicaciones[j].getId_ubicacion() + "> " + ubicaciones[j].getNombre()+"</option>");
                        }
                        out.println("</select></td>");
                        out.println("</tr>");
                        
                        
                        %>
                        <tr >
                                <th colspan=2 class="nada">     </th>
                            </tr>
                            <tr >
                                <th class="nada" colspan=2>
                                    <input type="button" name="btnGuardar" value="Enviar" onclick="evalua(this.form)"> <input type="button" name="btnCancelar" value="Cancelar" onclick="location.href = 'GestionarSolicitudes_de_Reserva?hacer=Listar' ">
                                </th>
                       </tr>
                        </tbody>
                    </table>
                </form>
                <!-- B.3 SUBCONTENT -->
            </div>            
            <!-- C. FOOTER AREA -->   
            <!-- C. FOOTER AREA --> 
            </div>
            <%@include file="../footer.jsp"%>    
        </div>
    </body>
</html>